<template>
  <div class="divBox">
    <el-card class="box-card">
<!--      <el-form inline size="small" @submit.native.prevent>-->
<!--        <el-form-item label="关键词：">-->
<!--          <el-input v-model="listPram.keyword" placeholder="关键词" clearable class="selWidth"/>-->
<!--        </el-form-item>-->
<!--&lt;!&ndash;        <el-form-item label="地区:" prop="areaId">&ndash;&gt;-->
<!--&lt;!&ndash;          <el-cascader class="col"&ndash;&gt;-->
<!--&lt;!&ndash;                       placeholder="可输入地区名称进行搜索"&ndash;&gt;-->
<!--&lt;!&ndash;                       v-model="value"&ndash;&gt;-->
<!--&lt;!&ndash;                       :options="options"&ndash;&gt;-->
<!--&lt;!&ndash;                       clearable&ndash;&gt;-->
<!--&lt;!&ndash;                       :props="{ expandTrigger: 'hover' }"&ndash;&gt;-->
<!--&lt;!&ndash;                       filterable&ndash;&gt;-->
<!--&lt;!&ndash;                       @change="handleChange"></el-cascader>&ndash;&gt;-->
<!--&lt;!&ndash;        </el-form-item>&ndash;&gt;-->
<!--        <el-form-item>-->
<!--          <el-button icon="el-icon-search" size="mini" type="primary" @click.native="getList">搜索</el-button>-->
<!--          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
<!--        </el-form-item>-->
<!--        <el-form-item class="el-form-item-align-right">-->
<!--          <el-button icon="el-icon-circle-plus" size="mini" type="primary" @click="openEdit()"-->
<!--                     v-has-permi="['admin:entrepreneurs:save']">添加-->
<!--          </el-button>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
      <el-table :data="listData.list"
                :header-cell-style=" {fontWeight:'bold',background:'#f8f8f9',color: '#515a6e',height:'40px'}"
                border size="mini">
        <el-table-column width="120" label="ID" prop="id"></el-table-column>
        <el-table-column label="封面" prop="businessFace" width="400">
          <template slot-scope="scope">
            <el-image
                referrerpolicy="no-referrer"
                style="width: 66px!important; height: 66px!important;"
                :src="imageUrl + scope.row.businessFace"
                :preview-src-list="[scope.row.businessFace]"
            />
          </template>
        </el-table-column>
        <el-table-column label="创业名称" min-width="130" prop="name"/>
<!--        <el-table-column label="所在地区" min-width="130" prop="areaText"/>-->
<!--        <el-table-column label="标签" min-width="100" prop="label"/>-->
<!--        <el-table-column label="地址" min-width="130" prop="address"/>-->
        <el-table-column align="center" fixed="right" label="操作" min-width="180">
          <template slot-scope="scope">
            <el-button v-has-permi="['admin:entrepreneurs:application']" icon="el-icon-edit" size="mini" type="success"
                       @click="applicationEdit(scope.row.id)">报名列表
            </el-button>
            <el-button v-has-permi="['admin:entrepreneurs:save']" icon="el-icon-edit" size="mini" type="primary"
                       @click="openEdit(scope.row.id)">编辑
            </el-button>
            <el-button v-has-permi="['admin:entrepreneurs:delete']" icon="el-icon-delete" size="mini" type="danger"
                       @click="handlerDelete(scope.row.id)">删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          :current-page="listPram.page"
          :page-sizes="[20,40,60,80,100]"
          :total="listData.count"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </el-card>
    <el-dialog
        :close-on-click-modal="false"
        :title="editDialog.id? '编辑':'新增'"
        :visible.sync="editDialog.show"
        destroy-on-close
        top="60px"
        width="1200px">
      <edit
          v-if="editDialog.show"
          :id="editDialog.id"
          :businessTypeList="editDialog.businessTypeList"
          ref="editForm"
          @hideEditDialog="hideEditDialog"
      />
    </el-dialog>
    <el-dialog
        :close-on-click-modal="false"
        :title="'报名列表'"
        :visible.sync="applicationDialog.show"
        destroy-on-close
        top="60px"
        width="1200px">
      <application
          v-if="applicationDialog.show"
          :id="applicationDialog.id"
          ref="editForm"
          @hideEditDialog="hideEditDialog"
      />
    </el-dialog>
  </div>
</template>

<script>
import edit from './edit.vue'
import {deleteRow,list} from "@/api/entrepreneurs";
import {checkPermi} from "@/utils/permission";
import Application from "@/views/operate/entrepreneurs/application.vue";
import {optionsList} from "@/api/business";

export default {
  components: {Application, edit},
  data() {
    return {
      listData: {list: [], count: 0},
      listPram: {
        keyword: '',
        areaId:'',
        page: 0,
        limit: 20,
      },
      editDialog: {
        show: false,
        id: null,
        businessTypeList:[],
      },
      applicationDialog: {
        show: false,
        id: null,
      },
      editDialogList: {
        show: false,
        id: null,
        editDate: {},
        pid: null
      },
      tableLoading: false,
      imageUrl: '',
      value: [],
      options: [{
        value: '',
        label: '',
        children: [{
          value: '',
          label: '',
          children: [{
            value: '',
            label: ''
          }]
        }]
      }],
    }
  },
  mounted() {
    this.imageUrl = process.env.VUE_APP_IMAGE_URL
    this.getList()
    this.getOptions()
  },
  methods: {
    handleChange(value) {
      this.listPram.areaId = value[2]
    },
    getOptions() {
      optionsList().then(res => {
        this.options = res
      })
    },
    checkPermi,
    getList() {
      this.tableLoading = true
      list(this.listPram).then(res => {
        this.listData = res;
      }).finally(() => {
      })
      this.tableLoading = false;
    },
    openEdit(id = null) {
      this.editDialog.id = id;
      this.editDialog.show = true
    },
    applicationEdit(id = null) {
      this.applicationDialog.id = id;
      this.applicationDialog.show = true
    },
    openEditList(id = null, editDate) {
      this.editDialogList.id = id;
      this.editDialogList.show = true
      this.editDialogList.editDate = editDate
    },
    handlerDelete(id) {
      this.$confirm('确认删除该数据吗？').then(() => {
        const loading = this.$loading({text: '删除中', background: 'rgba(255,255,255,.5)'})
        deleteRow(id).then(() => {
          this.$message.success('删除成功')
          this.getList()
        }).finally(() => {
          loading.close()
        })
      })
    },
    hideEditDialog() {
      this.editDialog.show = false
      this.applicationDialog.show = false
      this.getList()
    },
    editListDialog() {
      this.editDialogList.show = false
      this.getList()
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.getList()
    },
    resetQuery() {
      this.listPram.keyword = '';
      // this.listPram.areaId = '';
      this.value = ''
      this.getList()
    }
  }
}
</script>

<style scoped lang="scss">

</style>

<style scoped>

</style>
